package lc.动态规划;

/**
 * @description:
 * @author: qian
 * @createDate: 2021/10/19
 */
public class 剑指Offer63_股票的最大利润 {

    public int maxProfit(int[] prices) {

        if(prices == null || prices.length <= 1) {
            return 0;
        }
        int min = prices[0];
        int res = 0;
        for (int i = 1; i < prices.length; i++) {
            min = Math.min(min,prices[i - 1]);
            res = Math.max(res,prices[i] - min);

        }
        return res;
    }


}
